package com.bestcem.xm.component.mybatis.base;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @ClassName: BaseEntity
 * @Description: 创建人 更新人不是全都有这个字段，先不处理
 * @Author: chenglong.yue
 * @Date: 2022/7/21 18:06
 */
@Getter
@Setter
public class BaseEntity implements Serializable {

    @TableField(value = "created_id")
    @JsonProperty("created_id")
    private String createdId;

    @TableField(value = "updated_id")
    @JsonProperty("updated_id")
    private String updatedId;

    @TableField(value = "version_id", fill = FieldFill.INSERT)
    @Version
    @JsonProperty("version_id")
    private Integer versionId;

    @TableField(value = "deleted", fill = FieldFill.INSERT)
    @TableLogic
    @JsonProperty("deleted")
    private Boolean deleted;

    /**
     * 创建时间
     */
    @TableField(value = "created_dt", fill = FieldFill.INSERT)
    @JsonProperty("created_dt")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8")
    @JSONField(name = "created_dt", format = "yyyy/MM/dd HH:mm:ss")
    private LocalDateTime createdDt;

    /**
     * 更新时间
     */
    @TableField(value = "updated_dt", fill = FieldFill.INSERT_UPDATE)
    @JsonProperty("updated_dt")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8")
    @JSONField(name = "updated_dt", format = "yyyy/MM/dd HH:mm:ss")
    private LocalDateTime updatedDt;

}